using ASP;
using System;
using System.Configuration;
using System.Data.Common;
using System.Data.SqlClient;
using System.Globalization;
using System.Threading;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;


public partial class FilterHeadingTemplate : Page, IRequiresSessionState
{
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        this.gvwHeadingTemplate.DataBind();
    }

    protected void gvwHeadingTemplate_SelectedIndexChanged(object sender, EventArgs e)
    {
        string Result = this.gvwHeadingTemplate.DataKeys[this.gvwHeadingTemplate.SelectedIndex]["HeadingCode"].ToString();
        string Result2 = this.gvwHeadingTemplate.DataKeys[this.gvwHeadingTemplate.SelectedIndex]["Section"].ToString();
        if (this.Session["SelectedHeadingCode"] != null)
        {
            this.Session["SelectedHeadingCode"] = Result;
            this.Session["SelectedHeadingSection"] = Result2;
        }
        else
        {
            this.Session.Add("SelectedHeadingCode", Result);
            this.Session.Add("SelectedHeadingSection", Result2);
        }
        string scriptStr = "<script>window.close();</script>";
        base.ClientScript.RegisterClientScriptBlock(typeof(string), "closing", scriptStr);
    }

    protected override void InitializeCulture()
    {
        string sCulture = ConfigurationManager.AppSettings["DefaultCulture"].ToString();
        try
        {
            sCulture = this.Session["Culture"].ToString();
        }
        catch (NullReferenceException)
        {
        }
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(sCulture);
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(sCulture);
        base.InitializeCulture();
    }

    protected void ODSHeadingTemplate_Selecting1(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        SqlParameter[] sqlparam = new SqlParameter[2];
        sqlparam[0] = new SqlParameter();
        sqlparam[0].ParameterName = "@HeadingCode";
        sqlparam[0].Value = this.txtHeadingTemplate.Text;
        sqlparam[1] = new SqlParameter();
        sqlparam[1].ParameterName = "@HeadingName";
        sqlparam[1].Value = "";
        DbParameter[] param = sqlparam;
        e.InputParameters[0] = "_IPMS_HeadingTemplateSearch_Sp";
        e.InputParameters[1] = param;
    }
}
